

#import "leftBarButtonItems+rightBarButtonItems.h"

#import "JTCSM.h"

@implementation leftBarButtonItems_rightBarButtonItems

- (UIBarButtonItem *)setBarButtonItemsImageName:(NSString *)name  frame:(CGRect)frame target:(id)target SEL:(SEL)action{
    UIImage * firstImage = [UIImage imageNamed:name];
//    CGRect firstFrame = frame;
//    CGFloat width = frame.size.width;
    CGFloat height = frame.size.height;
    CGFloat imagesize = 20;
    UIButton * leftButton = [[UIButton alloc]initWithFrame:frame];
//    leftButton.frame = ;
    [leftButton setImage:firstImage forState:UIControlStateNormal];
    [leftButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
//    [leftButton setTitle:@"返回" forState:UIControlStateNormal];
//    //        image的位置大小调整
    leftButton.imageEdgeInsets = UIEdgeInsetsMake((height-imagesize)/2, 0, (height-imagesize)/2, height-imagesize);
//    //        title的位置大小调整
//    leftButton.titleEdgeInsets = UIEdgeInsetsMake(0,-imagesize+10, 0, 0);
//    [leftButton setTitleColor:RGBACOLOR(0, 0, 0, 1) forState:UIControlStateNormal];

    UIBarButtonItem * firstBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];

    return firstBarButtonItem;
}
- (UIBarButtonItem *)setBarButtonItemsTitle:(NSString *)title  frame:(CGRect)frame target:(id)target SEL:(SEL)action{
    CGRect firstFrame = frame;
    
    UIButton * leftButton = [[UIButton alloc] initWithFrame:firstFrame];
    [leftButton setTitle:title forState:UIControlStateNormal];
    leftButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [leftButton setTitleColor:RGBACOLOR(100, 100, 100, 1) forState:UIControlStateNormal];
    [leftButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * firstBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];

    return firstBarButtonItem;
}

- (UIBarButtonItem *)setBarButtonOnlyItemsImageName:(NSString *)title  frame:(CGRect)frame target:(id)target SEL:(SEL)action{
    CGRect firstFrame = frame;
    CGFloat width = frame.size.width;
    CGFloat height = frame.size.height;
    CGFloat imagesize = 20;
    UIButton * leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    leftButton.frame = firstFrame;
    [leftButton setImage:[UIImage imageNamed:title] forState:UIControlStateNormal];
    [leftButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    leftButton.imageEdgeInsets = UIEdgeInsetsMake((height-imagesize)/2, (width-imagesize)/2, (height-imagesize)/2, (width-imagesize)/2);
    UIBarButtonItem * firstBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    
    return firstBarButtonItem;
}


@end
